package com.mall.web.controller.org.app;

import com.mall.common.annotation.Log;
import com.mall.common.core.controller.BaseController;
import com.mall.common.core.domain.AjaxResult;
import com.mall.common.core.page.TableDataInfo;
import com.mall.common.enums.BusinessType;
import com.mall.org.students.domain.StudentDto;
import com.mall.org.students.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 学生Controller
 * 
 * @author mall
 * @date 2024-05-08
 */
@RestController
@RequestMapping("/app/org/students")
public class AppStudentsController extends BaseController
{
    @Autowired
    private IStudentService studentService;

    /**
     * 查询学生列表
     */
    @GetMapping("/list")
    public AjaxResult list(StudentDto studentDto)
    {
        List<StudentDto> list = studentService.selectStudentList(studentDto);
        return success(list);
    }

    /**
     * 获取学生详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(studentService.selectStudentById(id));
    }

    /**
     * 删除学生
     */
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(studentService.deleteStudentById(id));
    }

    /**
     * 新增学生
     */
    @PostMapping("save")
    public AjaxResult save(@RequestBody StudentDto studentDto)
    {
        return toAjax(studentService.saveStudentInfo(studentDto));
    }


}
